<template>
  <view class="bg-white flex h-36 px-12 py-10 items-center">
    <image class="block w-78 h-26" src="@/static/img/logo.png" @click="$Router.pushTab('/pages/index/index')" />
    <view class="flex-1 px-10">
      <uni-search-bar
        :style="{padding: 0}"
        radius="18"
        placeholder="请输入文档搜索关键词"
        bg-color="#F5F7FB"
        clear-button="auto"
        cancel-button="none"
        @confirm="search"
      />
    </view>
    <image class="block rounded w-28 h-28" :src="user.headimgurl || avatar" mode="" @click="goUser" />
  </view>
</template>

<script>
import avatar from '@/static/img/avatar.png'
export default {
  data() {
    return {
      avatar
    }
  },
  computed: {
    user() {
      return this.$store.state.userInfo
    }
  },
  methods: {
    search(e) {
      if (e.value) {
        this.$Router.push({ path: '/pages/index/nav', query: { keyword: e.value }})
      }
    },
    goUser() {
      if (this.user.id) {
        this.$Router.push('/pages/user/info')
      } else {
        this.$Router.push('/pages/login/index')
      }
    }
  }
}
</script>

<style lang="scss">
.w-78 {
	width: 156rpx;
}
</style>
